package com.puzzlebazar.client.util;

import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.Focusable;


public interface LabeledField extends Field, Focusable {

	/**
	 * Resets any error message associated with this field
	 */
	public void resetError();

	/**
	 * Sets a specific error message for this field
	 * 
	 * @param errorText The text to put in the error field
	 */
	public void setError(String errorText);

	/**
	 * Checks if the field is currently displaying an error 
	 * 
	 * @return True if it is displaying an error, false otherwise
	 */
	public boolean hasError();

	/**
	 * Access the content of the textbox associated with this field
	 * 
	 * @return The text contained in the textbox
	 */
	public String getEntry();
	
	/**
	 * Adds a validation pass to the textbox
	 * 
	 * @param callback The callback to use for validation
	 */
	public void addValidationCallback( ValidationCallback callback );
	
	
	/**
	 * Adds a handler to be executed when entry changes
	 * 
	 * @param handler The handler
	 */
	public void addChangeHandler( ChangeHandler handler );	
	
	/**
	 * Re-runs all validation callbacks and updates error message in consequence
	 */
	public void validate();

}